<%-- 
    Document   : historique
    Created on : 21 avr. 2013, 18:06:22
    Author     : xarckane
--%>

<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="local.ctl.ctlHisto"%>
<%@page import="shared.Memory"%>
<%@page import="shared.Process"%>
<%@page import="local.Historique.Type"%>
<%@page import="shared.Cpu"%>
<%@page import="persistance.DaoHistorique"%>
<%@page import="local.Historique"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
               <link rel="stylesheet" type="text/css" href="/TpMonitoringJu/css/bootstrap.css" >
        <link rel="javascript" type="text/javascript" href="/TpMonitoringJu/js/bootstrap.js">
        <link rel="javascript" type="text/javascript" href="/TpMonitoringJu/js/jquery.spin.js">
        <link rel="javascript" type="text/javascript" href="/TpMonitoringJu/js/spin.min.js">

    </head>
    <body>
        <%     if (request.getParameter("histo") != null) {%>

        <table class="table table-condensed"> 
            <tr>
                <td>details</td>
                <td>serveur</td>
                <td>type</td>
                <td>date</td>


            </tr>


            <% for (Historique histolist : ((ArrayList<Historique>)(request.getAttribute("historique")))) {%>
            <tr><td> <form name="form_action" method="post" action="action">
                        <input type="hidden" name="action" value="detailledHisto">
                        <input type="hidden" name="id" value="<%= histolist.getId()%>">
                        <input type="hidden" name="serv" value="<%= histolist.getServeur()%>">
                        <input type="hidden" name="type" value="<%= histolist.getType()%>">
                        <input type="hidden" name="date" value="<%= histolist.getDateTime()%>">
                        <input type="submit" value="details"></form> </td>
                <td> <%= histolist.getServeur()%></td>
                <td> <%=  histolist.getType()%></td>
                <td> <%=  histolist.getDateTime()%></td>
</tr>
            <%  }%>
        </table>    


        <% }
        if (request.getParameter("action").equals("detailledHisto")){
         

              

                if (((Historique)request.getAttribute("myhisto")).getType().toString().equalsIgnoreCase("cpu")) {
        %>   
        <table border="1" bordercolor="#330000" style="background-color:#FFFFFF" width="100%" cellpadding="3" cellspacing="3"> 
            <tr>
                <td>us: user cpu time (or) % CPU time spent in user space</td>
                <td>sy: system cpu time (or) % CPU time spent in kernel space</td>
                <td>ni: user nice cpu time (or) % CPU time spent on low priority processes</td>
                <td>id: idle cpu time (or) % CPU time spent idle</td>
                <td>wa: io wait cpu time (or) % CPU time spent in wait (on disk)</td>
                <td>hi: hardware irq (or) % CPU time spent servicing/handling hardware interrupts</td>
                <td>si: software irq (or) % CPU time spent servicing/handling software interrupts</td>
                <td>st: steal time - - % CPU time in involuntary wait by virtual cpu while hypervisor is servicing another processor (or) % CPU time stolen from a virtual machine
                <td>load1</td>
                <td>load5</td>
                <td>load15</td>

            </tr>


            <%
               
                System.err.println();
            %>
            <tr><td> <%= ((Cpu) ((Historique)request.getAttribute("myhisto")).getObject()).getUs()%></td>
                <td> <%=  ((Cpu) ((Historique)request.getAttribute("myhisto")).getObject()).getSy()%></td>
                <td> <%=  ((Cpu) ((Historique)request.getAttribute("myhisto")).getObject()).getNi()%></td>
<td> <%=  ((Cpu)((Historique)request.getAttribute("myhisto")).getObject()).getId()%></td>
<td> <%=  ((Cpu) ((Historique)request.getAttribute("myhisto")).getObject()).getWa()%></td>
<td> <%=  ((Cpu) ((Historique)request.getAttribute("myhisto")).getObject()).getHi()%></td>
<td> <%=  ((Cpu) ((Historique)request.getAttribute("myhisto")).getObject()).getSi()%></td>
<td> <%=  ((Cpu) ((Historique)request.getAttribute("myhisto")).getObject()).getSt()%></td>
<td> <%=  ((Cpu) ((Historique)request.getAttribute("myhisto")).getObject()).getLoa1()%></td>
<td> <%=  ((Cpu)((Historique)request.getAttribute("myhisto")).getObject()).getLoa5()%></td>
<td> <%=  ((Cpu) ((Historique)request.getAttribute("myhisto")).getObject()).getLoa15()%></td>
</tr>

        </table>  
        <%      }
            if (((Historique)request.getAttribute("myhisto")).getType().toString().equalsIgnoreCase("mem")) {
        %>   

        <table border="1" bordercolor="#330000" style="background-color:#FFFFFF" width="100%" cellpadding="3" cellspacing="3"> 
            <tr>
                <td>free</td>
                <td>used</td>
                <td>total</td>


            </tr>

            
            <tr><td> <%= ((Memory) ((Historique)request.getAttribute("myhisto")).getObject()).getFree()%></td>
                <td> <%=  ((Memory) ((Historique)request.getAttribute("myhisto")).getObject()).getTotal()%></td>
                <td> <%=  ((Memory) ((Historique)request.getAttribute("myhisto")).getObject()).getUsed()%></td></tr>


        </table>  
        <%      }
            if (((Historique)request.getAttribute("myhisto")).getType().toString().equalsIgnoreCase("process")) {
        %>   

        <table border="1" bordercolor="#330000" style="background-color:#FFFFFF" width="100%" cellpadding="3" cellspacing="3"> 
            <tr>
                <td>nom</td>
                <td>pid</td>



            </tr>


            <%
               
                for (shared.Process proc : ((shared.ProcessList) ((Historique)request.getAttribute("myhisto")).getObject()).getListe()) {
            %>
            <tr><td> <%= proc.getName()%></td>
                <td> <%= proc.getPid()%></td>

                <% }
                } 
                
                       }
                %>
        </table>  
        <form name="form_action" method="post" action="action"> <button class="btn" type="submit" name="delete" value="clear">clear</button></form>
       
    </body>
</html>
